﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ForumServer;
using log4net;
using ForumServer.Logger;
using System.Runtime.Remoting.Channels.Tcp;
using System.Runtime.Remoting.Channels;
using System.Runtime.Serialization.Formatters;
using System.Collections;

namespace ForumGUI
{
    public class ClientConfiguration2
    {
        public static void configure()
        {
            //------------------------Client Configuration------------------------//


            BinaryClientFormatterSinkProvider clientProvider = new BinaryClientFormatterSinkProvider();
            BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider();
            serverProvider.TypeFilterLevel = TypeFilterLevel.Full;

            IDictionary props = new Hashtable();
            props["port"] = 0;
            string s = System.Guid.NewGuid().ToString();
            props["name"] = s;
            props["typeFilterLevel"] = TypeFilterLevel.Full;
            TcpChannel x_channel = new TcpChannel(props, clientProvider, serverProvider);

            try
            {
                ChannelServices.RegisterChannel(x_channel, false);
            }
            catch
            {
                //logger.Fatal("Failed to register to tcp channel");
            } 

        }

    }
}
